<template>
	<view class="content">
		<view class="navbar">
			<view  class="navbaritem"   v-for="(item,index) of title" :key=index @click="navto(index)">
				<text :class="currentIndex==index?'botline':''">{{item.title}}</text>
			</view>	
		</view>
		<view class="xiaofei" v-if="currentIndex==0">
			<view class="" v-if="listxiaohao.length==0">
				暂无内容
			</view>
			<view class="xiaofeibox" v-for="(item, index) of listxiaohao" :key = "index">
				<view class="row1">
					<view class="zuo">
						{{item.create_at|formatDate}}
					</view>
					<view class="you">
						<view >{{item.amount}}</view>
						<view >{{item.note}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="xitong" v-if="currentIndex==1">
			
			<view v-if="listxitong.length==0">
				暂无内容
			</view>
			<view v-else>
				<view class="xiaofeibox" v-for="(item, index) of listxitong" :key = "index">
					<view class="row1">
						<view class="zuo">
							{{item.create_at|formatDate}}
						</view>
						<view class="you">
							<view >{{item.amount}}</view>
							<view >{{item.note}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:[
					{
						id:1,
						title:'消耗记录'
					},
					{
						id:2,
						title:'系统记录'
					}
				],
				currentIndex:0,
				listxiaohao:[],
				listxitong:[],
			}
		},
		onLoad() {
			this.getinfo()
		},
		methods: {
			navto(index){
				 this.currentIndex = index
			},
			getinfo(){
				var token =uni.getStorageSync('token')
				if(token==''||token==null){
					uni.reLaunch({
					    url:'../login/login'
					})
				}else{
					this.http({
					 	url:'/api/Page/consumeLogs',
					 	method:'POST',
						header:{
							'token':token
						},
						data:{
							type:1
						},
					 	success:(res)=>{
							console.log(res)
							this.listxiaohao =res.data
						},
					 	error:()=>{
					 		uni.showToast({
					 			title:"请求异常"	
					 		})
					 	},	
					 })
					 this.http({
					  	url:'/api/Page/consumeLogs',
					  	method:'POST',
					 	header:{
					 		'token':token
					 	},
					 	data:{
					 		type:2
					 	},
					  	success:(res)=>{
					 		console.log(res)
					 		this.listxitong =res.data
					 	},
					  	error:()=>{
					  		uni.showToast({
					  			title:"请求异常"	
					  		})
					  	},	
					  })
				}
			}
		}
	}
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		font-family: PingFang SC;
		font-weight: 500;
		color:#2b2b2b;
		padding-bottom: 50rpx;
		.navbar{
			width: 690rpx;
			height: 98rpx;
			margin: 20rpx auto;
			display: flex;
			justify-content: space-around;
			.navbaritem{	
				height: 98rpx;
				font-size: 30rpx;
				font-weight: bold;
				color: #2B2B2B;
				line-height: 98rpx;
				text-align: center;
			}
		}
		.botline{
			color: #007AFF;
			padding-bottom: 5px;
			border-bottom:  4px solid #007AFF;
		}
		.xiaofeibox{
			width: 690rpx;
			height: 88rpx;
			background: #FFFFFF;
			box-shadow: 0px 0px 2px 0px rgba(43, 43, 43, 0.18);
			border-radius: 10rpx;
			margin: 10rpx auto;
			font-size: 28rpx;
			.row1{
				width: 628rpx;
				margin: 0 auto;
				display: flex;
				justify-content: space-between;
				align-items: center;
				.you{
					text-align: end;
					.teshu{	
						color: #0072FF;
						margin-top: 10rpx;
					}
				}
			}
		}
		
	}

	
</style>
